home *** CD-ROM | disk | FTP | other *** search
/ Professional Soft Collection 1.02 / Professional Soft Collection 1.02.iso / archivat / arj242a.exe / TECHNOTE.DOC < prev    next >
Text File  |  1994-12-30  |  9KB  |  230 lines

  1.  
  2.      ARJ TECHNICAL INFORMATION                               November 1994
  3.  
  4.  
  5.      ** IMPORTANT NEWS ****************************************************
  6.  
  7.      Some archiver support programs have designed ARJ archive
  8.      identification schemes that are not reliable.  At ARJ 2.39, there are
  9.      now two versions of the large self-extraction module.  The 17K byte
  10.      ARJSFX module supports ARJ-SECURITY.  The standard 15K byte ARJSFX
  11.      module does NOT support ARJ-SECURITY.  For the first time, the
  12.      ARJ-SECURITY fields in the main ARJ header are publicly defined.
  13.  
  14.      In addition, the main ARJ header in self-extracting archives MAY NOT
  15.      immediately follow the EXE module now.
  16.  
  17.      ARJ has used the same ARJ archive identification scheme since ARJ
  18.      1.0.  The following is the algorithm:
  19.  
  20.      (1) find the ARJ header id bytes 0x60, 0xEA,
  21.      (2) read the next two bytes as the header record size in bytes,
  22.      (3) if the record size is greater than 2600, go back to the header
  23.      id file position, increment the file position, and go back to
  24.      step (1),
  25.      (4) read the header record based upon the previous byte count,
  26.      (5) calculate the 32 bit CRC of the header record data,
  27.      (6) read the next four bytes as the actual header record CRC,
  28.      (7) if the actual CRC does not equal the calculated CRC, go back
  29.      to the header id file position, increment the file position,
  30.      and go back to step (1).
  31.  
  32.      It is acceptable to start this identification algorithm at a point
  33.      just after the ARJ self-extraction portion of an archive.  This
  34.      algorithm is fully demonstrated in the UNARJ C source code. A portion
  35.      of that source code is excerpted at the end of this document.
  36.  
  37.      When using listfiles with ARJ, ARJ support programs should use the
  38.      "-p" option to ensure that ARJ will only extract the selected files
  39.      from an ARJ archive.  In addition, the listfiles should contain the
  40.      full pathname information as stored in the ARJ archive.  This avoids
  41.      the problem accessing files that have the same filename but different
  42.      paths.
  43.  
  44.      There is an extended header bug in older versions of ARJ, AV.C and
  45.      UNARJ.C.  The extended header processing in read_header() should
  46.      skip 4 bytes for the extended header CRC and not 2.  This is NOT a
  47.      current problem as no versions of ARJ use the extended header.
  48.  
  49.      **********************************************************************
  50.  
  51.  
  52.      Modification history:
  53.      Date      Description of modification:
  54.      --------  ------------------------------------------------------------
  55.      11/03/94  Improved SFX identification information.
  56.      01/21/94  Added find_header() routine.
  57.      03/17/93  Added information about ARJSFX change.
  58.      02/17/93  Added description of ARJ security fields.
  59.            Added archive date-modified field.
  60.      12/03/91  Added BACKUP flag to header arj flags.
  61.      11/21/91  Described the two types of headers separately.
  62.      11/11/91  Added information about the change in text mode processing.
  63.      06/28/91  Added several new HOST OS numbers.
  64.      05/19/91  Improved the description of extended header processing.
  65.      05/11/91  Simplified this document.  Added volume label type.
  66.      03/11/91  Added directory file type.
  67.      02/23/91  Added more comments.
  68.      01/10/91  Corrected timestamp description and header order of file mode.
  69.      10/30/90  Corrected values of flags in ARJ flags.
  70.  
  71.  
  72.      ARJ archives contains two types of header blocks:
  73.  
  74.     Archive main header - This is located at the head of the archive
  75.     Local file header   - This is located before each archived file
  76.  
  77.      Structure of main header (low order byte first):
  78.  
  79.      Bytes Description
  80.      ----- -------------------------------------------------------------------
  81.        2   header id (main and local file) = 0x60 0xEA
  82.        2   basic header size (from 'first_hdr_size' thru 'comment' below)
  83.          = first_hdr_size + strlen(filename) + 1 + strlen(comment) + 1
  84.          = 0 if end of archive
  85.          maximum header size is 2600
  86.  
  87.        1   first_hdr_size (size up to and including 'extra data')
  88.        1   archiver version number
  89.        1   minimum archiver version to extract
  90.        1   host OS   (0 = MSDOS, 1 = PRIMOS, 2 = UNIX, 3 = AMIGA, 4 = MAC-OS)
  91.              (5 = OS/2, 6 = APPLE GS, 7 = ATARI ST, 8 = NEXT)
  92.              (9 = VAX VMS)
  93.        1   arj flags
  94.              (0x01 = NOT USED)
  95.              (0x02 = OLD_SECURED_FLAG)
  96.              (0x04 = VOLUME_FLAG)  indicates presence of succeeding
  97.                        volume
  98.              (0x08 = NOT USED)
  99.              (0x10 = PATHSYM_FLAG) indicates archive name translated
  100.                        ("\" changed to "/")
  101.              (0x20 = BACKUP_FLAG) indicates backup type archive
  102.              (0x40 = SECURED_FLAG)
  103.        1   security version (2 = current)
  104.        1   file type        (must equal 2)
  105.        1   reserved
  106.        4   date time when original archive was created
  107.        4   date time when archive was last modified
  108.        4   archive size (currently used only for secured archives)
  109.        4   security envelope file position
  110.        2   filespec position in filename
  111.        2   length in bytes of security envelope data
  112.        2   (currently not used)
  113.        ?   (currently none)
  114.  
  115.        ?   filename of archive when created (null-terminated string)
  116.        ?   archive comment  (null-terminated string)
  117.  
  118.        4   basic header CRC
  119.  
  120.        2   1st extended header size (0 if none)
  121.        ?   1st extended header (currently not used)
  122.        4   1st extended header's CRC (not present when 0 extended header size)
  123.  
  124.  
  125.      Structure of local file header (low order byte first):
  126.  
  127.      Bytes Description
  128.      ----- -------------------------------------------------------------------
  129.        2   header id (main and local file) = 0x60 0xEA
  130.        2   basic header size (from 'first_hdr_size' thru 'comment' below)
  131.          = first_hdr_size + strlen(filename) + 1 + strlen(comment) + 1
  132.          = 0 if end of archive
  133.          maximum header size is 2600
  134.  
  135.        1   first_hdr_size (size up to and including 'extra data')
  136.        1   archiver version number
  137.        1   minimum archiver version to extract
  138.        1   host OS   (0 = MSDOS, 1 = PRIMOS, 2 = UNIX, 3 = AMIGA, 4 = MAC-OS)
  139.              (5 = OS/2, 6 = APPLE GS, 7 = ATARI ST, 8 = NEXT)
  140.              (9 = VAX VMS)
  141.        1   arj flags (0x01 = GARBLED_FLAG) indicates passworded file
  142.              (0x02 = NOT USED)
  143.              (0x04 = VOLUME_FLAG)  indicates continued file to next
  144.                        volume (file is split)
  145.              (0x08 = EXTFILE_FLAG) indicates file starting position
  146.                        field (for split files)
  147.              (0x10 = PATHSYM_FLAG) indicates filename translated
  148.                        ("\" changed to "/")
  149.              (0x20 = BACKUP_FLAG)  indicates file marked as backup
  150.        1   method    (0 = stored, 1 = compressed most ... 4 compressed fastest)
  151.        1   file type (0 = binary,    1 = 7-bit text)
  152.              (3 = directory, 4 = volume label)
  153.        1   reserved
  154.        4   date time modified
  155.        4   compressed size
  156.        4   original size (this will be different for text mode compression)
  157.        4   original file's CRC
  158.        2   filespec position in filename
  159.        2   file access mode
  160.        2   host data (currently not used)
  161.        ?   extra data
  162.        4 bytes for extended file starting position when used
  163.        (these bytes are present when EXTFILE_FLAG is set).
  164.        0 bytes otherwise.
  165.  
  166.        ?   filename (null-terminated string)
  167.        ?   comment  (null-terminated string)
  168.  
  169.        4   basic header CRC
  170.  
  171.        2   1st extended header size (0 if none)
  172.        ?   1st extended header (currently not used)
  173.        4   1st extended header's CRC (not present when 0 extended header size)
  174.  
  175.        ...
  176.  
  177.        ?   compressed file
  178.  
  179.  
  180.      Time stamp format:
  181.  
  182.     31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
  183.        |<---- year-1980 --->|<- month ->|<--- day ---->|
  184.  
  185.     15 14 13 12 11 10  9  8  7  6  5  4  3    2  1  0
  186.        |<--- hour --->|<---- minute --->|<- second/2 ->|
  187.  
  188.  
  189.      Routine to find an ARJ Header record:
  190.  
  191.        long find_header(FILE *fd)
  192.        {
  193.            long arcpos, lastpos;
  194.            int c;
  195.  
  196.            arcpos = file_tell(fd);
  197.            file_seek(fd, 0L, SEEK_END);
  198.            lastpos = file_tell(fd) - 2;
  199.            for ( ; arcpos < lastpos; arcpos++)
  200.            {
  201.                file_seek(fd, arcpos, SEEK_SET);
  202.                c = fget_byte(fd);
  203.                while (arcpos < lastpos)
  204.                {
  205.                    if (c != HEADER_ID_LO)  /* low order first */
  206.                        c = fget_byte(fd);
  207.                    else if ((c = fget_byte(fd)) == HEADER_ID_HI)
  208.                        break;
  209.                    arcpos++;
  210.                }
  211.                if (arcpos >= lastpos)
  212.                    break;
  213.                if ((headersize = fget_word(fd)) <= HEADERSIZE_MAX)
  214.                {
  215.                    crc = CRC_MASK;
  216.                    fread_crc(header, (int) headersize, fd);
  217.                    if ((crc ^ CRC_MASK) == fget_crc(fd))
  218.                    {
  219.                        file_seek(fd, arcpos, SEEK_SET);
  220.                        return arcpos;
  221.                    }
  222.                }
  223.            }
  224.            return -1;          /* could not find a valid header */
  225.        }
  226.  
  227.  
  228.      end of document
  229.  
  230.